const api = require("../../../utils/api.js");
const app = getApp().globalData;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    active:-1,
    unitlist:[],
    hidden:true
  },
  //折叠面板单击事件
  getActive:function(res){
    let that = this;
    let active = res.currentTarget.dataset.active;
    if(active==that.data.active){
      active = -1;
    }
    that.setData({
      active:active
    });
  },
  //获取页面初始化数据
  getepData:function(that){
    let userData = wx.getStorageSync("USERDATA");
    let courseInfo = wx.getStorageSync("COURSEINFO");
    let url = "/study/getUnitlist";
    let parmas ={
      uid:userData.uid,
      sessionid:userData.sessionid,
      market:app.market,
      courseid:courseInfo.id,
      type:1,
      isPageing:0
    };
    api.sendPosts(url,parmas,function(res){
      that.setData({
        unitlist:res.unitlist
      });
    });
  },
  clickItem:async function(options){
    var that = this;
    let option={
      kipd:options.currentTarget.dataset.res.knowPointId,
      unitid:options.currentTarget.dataset.unitid
    };
    let hidden = await api.clickItem(option);
    that.setData({
      hidden:hidden
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    //获取页面初始化数据
    that.getepData(that);
  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})